import allure
from page_base.page_base import Base
from page_element.el_Roncoo import *
from utils.timer import sleep
import logging



class PageLogin(Base):
    """登录页面"""
    def page_login(self,username, pwd):
        # 打开龙果
        self.open_url(url)
        self.maximize_window()
        with allure.step(f"输入用户名: {username}"):
            self.send_keys(login_pe.login_username, username)
        with allure.step(f"输入密码: {pwd}"):
            self.send_keys(login_pe.login_pwd, pwd)
            self.keys_tab(login_pe.login_pwd)
        # 强制等待输入验证码
        sleep(5)
        with allure.step("点击登录按钮"):
            self.click(login_pe.login_btn)
        sleep(5)
        # 断言
        with allure.step("验证登录"):
            dy = self.text(home_pe.exit_text)
            assert '退出系统' == dy, '断言失败(验证失败)'
            print(f'断言的内容:退出系统 == {dy}')
            logging.info(f'断言的内容:退出系统 == {dy}')

